import { defHttp } from '@/utils/http/axios';
import { RequestEnum } from '@/enums/httpEnum';
import { ServicePrefixEnum } from '@/enums/commonEnum';
import type { AxiosRequestConfig } from 'axios';

const MODULAR = '/system/area';

export const Api = {
  GetAreaTree: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/tree`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetAreaByIp: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get-by-ip`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig
}


export const getAreaTree = () => {
  return defHttp.request({ ...Api.GetAreaTree})
}

// 获得 IP 对应的地区名
export const getAreaByIp = (ip: string) => {
  let params = {ip:ip}
  return defHttp.request({ ...Api.GetAreaByIp,params })
}

// 获得 IP 对应的地区名
// export const getAreaByIp = async (ip: string) => {
//   return await request.get({ url: '/system/area/get-by-ip?ip=' + ip })

